//
//  AboutWeViewController.m
//  LINNER
//
//  Created by Kendama on 2017/10/11.
//  Copyright © 2017年 weiwang. All rights reserved.
//

#import "AboutWeViewController.h"
#import "HtmlViewController.h"

@interface AboutWeViewController ()

@property (nonatomic, strong) UIImageView *logoImageView;

@property (nonatomic, strong) UILabel *versionsLabel;

@property (nonatomic, strong) UIButton *useButton;

@end

@implementation AboutWeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)refreshBaseControlValue
{
    
}


#pragma mark -- 点击事件
- (void)didClickUseButton
{
    HtmlViewController *vc = [HtmlViewController new];
    [self.navigationController pushViewController:vc animated:YES];
}

#pragma mark -- 懒加载
- (UIImageView *)logoImageView
{
    if(!_logoImageView)
    {
        UIView *superView = self.view;
        _logoImageView = [[UIImageView alloc]init];
        [superView addSubview:_logoImageView];
        _logoImageView.image = [UIImage imageNamed:@"about_logo"];
    }
    return _logoImageView;
}
- (UILabel *)versionsLabel
{
    if(!_versionsLabel)
    {
        UIView *superView = self.view;
        _versionsLabel = [[UILabel alloc]init];
        [superView addSubview:_versionsLabel];
        _versionsLabel.textAlignment = NSTextAlignmentCenter;
//        [_versionsLabel setFont:[UIFont systemFontOfSize:15]];
        [_versionsLabel setTextColor:[UIColor darkGrayColor]];
        NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
        _versionsLabel.text = [NSString stringWithFormat:@"%@v%@",MyNSLocalizedString(@"版本号"),[infoDictionary objectForKey:@"CFBundleShortVersionString"]];
        
    }
    return _versionsLabel;
}
- (UIButton *)useButton
{
    if(!_useButton)
    {
        UIView *superView = self.view;
        _useButton = [[UIButton alloc]init];
        [superView addSubview:_useButton];
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:MyNSLocalizedString(@"使用条款")];
        NSRange strRange = {0,[str length]};
        [str addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:strRange];
        [_useButton setAttributedTitle:str forState:UIControlStateNormal];
//        [_useButton setTitle:@"使用条款" forState:UIControlStateNormal];
//        [_useButton setTitle:<#(nullable NSString *)#> forState:UIControlStateSelected];
        [_useButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
//        [_useButton.titleLabel setFont:[UIFont systemFontOfSize:15]];
        [_useButton addTarget:self action:@selector(didClickUseButton) forControlEvents:UIControlEventTouchUpInside];
    }
    return _useButton;
}


- (void)masLayoutSubview
{
    __weak UIView *superView = self.view;
    [self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(superView.mas_top).with.offset(px1920Height(380));
        make.centerX.mas_equalTo(superView.mas_centerX);
    }];
    
    [self.versionsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.logoImageView.mas_bottom).with.offset(px1920Height(160));
        make.centerX.mas_equalTo(superView.mas_centerX);
    }];
    
    [self.useButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(superView.mas_bottom).with.offset(px1920Height(-80));
        make.centerX.mas_equalTo(superView.mas_centerX);
    }];
}

- (void)setNavigationStyle
{
    [self setNavigationBarTitle:MyNSLocalizedString(@"关于")];
    [self setLeftButtonImage:[UIImage imageNamed:@"tittle_back_nor"]];
}

@end
